// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/distributiondetail"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	DistributionDetail = cDistributionDetail{}
)

type cDistributionDetail struct{}

// List 查看分销记录详情列表
func (c *cDistributionDetail) List(ctx context.Context, req *distributiondetail.ListReq) (res *distributiondetail.ListRes, err error) {
	list, totalCount, err := service.SysDistributionDetail().List(ctx, &req.DistributionDetailListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.DistributionDetailListModel{}
	}

	res = new(distributiondetail.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出分销记录详情列表
func (c *cDistributionDetail) Export(ctx context.Context, req *distributiondetail.ExportReq) (res *distributiondetail.ExportRes, err error) {
	err = service.SysDistributionDetail().Export(ctx, &req.DistributionDetailListInp)
	return
}

// Edit 更新分销记录详情
func (c *cDistributionDetail) Edit(ctx context.Context, req *distributiondetail.EditReq) (res *distributiondetail.EditRes, err error) {
	err = service.SysDistributionDetail().Edit(ctx, &req.DistributionDetailEditInp)
	return
}

// View 获取指定分销记录详情信息
func (c *cDistributionDetail) View(ctx context.Context, req *distributiondetail.ViewReq) (res *distributiondetail.ViewRes, err error) {
	data, err := service.SysDistributionDetail().View(ctx, &req.DistributionDetailViewInp)
	if err != nil {
		return
	}

	res = new(distributiondetail.ViewRes)
	res.DistributionDetailViewModel = data
	return
}

// Delete 删除分销记录详情
func (c *cDistributionDetail) Delete(ctx context.Context, req *distributiondetail.DeleteReq) (res *distributiondetail.DeleteRes, err error) {
	err = service.SysDistributionDetail().Delete(ctx, &req.DistributionDetailDeleteInp)
	return
}